Libraries

Encoder

The Wiring Encoder library allows for easily reading and writing a position or angle from an encoder.

The encoders are sensors used to track the position or rotation rate of a shaft. Encoders generate pulses when moved, on each pulse triggering an event on the Wiring I/O board, for this reason the phaseA pin of an encoder can only be connected to a Wiring pin capable of generating external interrupts. The Encoder library works on pins 2, 3, 38 and 39, so only four encoders can be working at the a time.

 

Encoder()
Class for manipulating encoders attached to the Wiring hardware.

attach()
Attaches an encoder variable to an encoder connected to a pin.

detach()
detaches an encoder variable from a pin.

read()
Reads the encoder position or angle.

write()
Sets the encoder position or angle.

attached()
Returns whether or not en encoder is attached to a pin.